package web.beans;

import entity.Car.bo.CarBo;
import entity.Car.model.Car;
import util.CreatePDF;

import javax.faces.event.ValueChangeEvent;
import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by vanches on 13.1.15.
 */
public class CarSearchBean implements Serializable {
    private int brand_id;
    private int model_id;
    private double price_Min;
    private double priceMax;
    private CarBo carBo;
    private ArrayList<Car> searchCar;
    private CreatePDF createPDF;

    public void brandSet(ValueChangeEvent e) {
        if (e.getNewValue() != null && !e.getNewValue().toString().isEmpty())
            brand_id = Integer.parseInt(e.getNewValue().toString());
    }
    public void modelSet(ValueChangeEvent e) {
        if (e.getNewValue() != null && !e.getNewValue().toString().isEmpty())
            model_id = Integer.parseInt(e.getNewValue().toString());
    }

    public String search(){
        searchCar= (ArrayList<Car>) carBo.carSearch(carBo.getBrandId(brand_id),carBo.getModelId(model_id),price_Min,priceMax);
        return "searchOk";
    }

    public void exportPDF(){
        createPDF.exportListCar(searchCar);
    }



    //region GET and SET


    public int getBrand_id() {
        return brand_id;
    }

    public void setBrand_id(int brand_id) {
        this.brand_id = brand_id;
    }

    public int getModel_id() {
        return model_id;
    }

    public void setModel_id(int model_id) {
        this.model_id = model_id;
    }

    public double getPrice_Min() {
        return price_Min;
    }

    public void setPrice_Min(double price_Min) {
        this.price_Min = price_Min;
    }

    public double getPriceMax() {
        return priceMax;
    }

    public void setPriceMax(double priceMax) {
        this.priceMax = priceMax;
    }

    public CarBo getCarBo() {
        return carBo;
    }

    public void setCarBo(CarBo carBo) {
        this.carBo = carBo;
    }

    public ArrayList<Car> getSearchCar() {
        return searchCar;
    }

    public void setSearchCar(ArrayList<Car> searchCar) {
        this.searchCar = searchCar;
    }

    public CreatePDF getCreatePDF() {
        return createPDF;
    }

    public void setCreatePDF(CreatePDF createPDF) {
        this.createPDF = createPDF;
    }
//endregion
}
